﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace iReaper
{
    public partial class download : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Request.HttpMethod != "GET")
            {
                this.Response.End();
                return;
            }

            string id = this.Request.Params["id"];
            string type = this.Request.Params["type"];

            // neither side empty will cause a 404
            if (id == null || type == null)
            {
                return;
            }

            string url = DownloadUrlManager.Dict.GetUrl(id, type);
            if (null == url)
            {
                this.Response.StatusCode = 404;
                this.Response.End();
                return;
            }
            else
            {
                this.Response.Redirect(url);
                return;
            }
        }
    }
}
